import { Form } from 'ant-design-vue'
import { ref } from 'vue'

const { useForm } = Form

export function useDeptForm() {
  const show = ref(false)
  const loading = ref(false)
  const formModel = ref({
    parentId: '',
    deptName: '',
    orderNum: 0,
    leader: '',
    phone: '',
    email: '',
    status: '0'
  } as ICreateDeptDTO)
  const formRules = ref({
    parentId: [{ required: true, message: '请选择上级部门' }],
    deptName: [{ required: true, message: '请输入部门名称' }],
    orderNum: [{ required: true, message: '请输入显示排序' }]
  } as FormRules<ICreateDeptDTO>)

  const formRef = useForm(formModel, formRules)

  return {
    show,
    loading,
    formRef,
    formModel
  }
}
